package com.moter.one.wyydemo1.controller;

import com.moter.one.wyydemo1.entity.UserInfo;
import com.moter.one.wyydemo1.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
//根据传送的对象插入数据库
public class InsertUser {
    @Autowired
    UserInfoService userInfoService;
    @CrossOrigin//如果从直接从html页面访问就需要加上这个跨域，如果从controller到html访问InsertUser就可以不用加
    @RequestMapping("/InsertUser")
    public int InsertUserInfo(@RequestBody  UserInfo userInfo){
        System.out.println(userInfo);
        int i = userInfoService.insertUserInfoMapper(userInfo);
        System.out.println(i);
        if(i>0)return 0;//插入成功
        else return 1;//插入失败
    }
}
